package com.googlecode.gunncs.mechanism;

import java.util.ArrayList;

import com.googlecode.grtframework.vis.Displayer;
import com.googlecode.grtframework.vis.MountedPosition;
import com.googlecode.gunncs.mechanism.gui.RobotBaseGUI;

/**
 * 
 * @author ajc
 * 
 */
public class RobotBaseFactory {

	/**
	 * Construct a robot base that drives only the provided wheels to drivew
	 * 
	 * @param left
	 * @param right
	 * @return
	 */
	public static RobotBase createFromSingleWheels(IWheel left, IWheel right) {

		// SimWheelEncoder leftEncoder = new SimWheelEncoder();
		// SimWheelEncoder rightEncoder = new SimWheelEncoder();
		ArrayList<IWheel> leftEncoders = new ArrayList<IWheel>();
		ArrayList<IWheel> rightEncoders = new ArrayList<IWheel>();
		leftEncoders.add(left);
		rightEncoders.add(right);
		RobotBase base = new RobotBase(leftEncoders, rightEncoders);
		return base;
	}

	/**
	 * Constructs a full simulation robot base given initial position. Resultant
	 * RobotBase is fully started and ready.
	 * 
	 * @param d
	 * @param robotPosition
	 * @return
	 */
	public static RobotBase initSimulated(Displayer d,
			MountedPosition robotPosition, int wheelDistance, String name) {

		SimWheelEncoder leftEncoder = new SimWheelEncoder();
		SimWheelEncoder rightEncoder = new SimWheelEncoder();
		RobotBase base = createFromSingleWheels(leftEncoder, rightEncoder);

		RobotBaseGUI g = new RobotBaseGUI(d, leftEncoder, rightEncoder,
				robotPosition, wheelDistance, name);
		g.initiate();
		leftEncoder.initiate();
		rightEncoder.initiate();
		return base;
	}

}
